﻿<UserControl x:Class="SilverlightHVP.View.LinksView"
    xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
    xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
    xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
    xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
    mc:Ignorable="d"
    xmlns:this="clr-namespace:SilverlightHVP.View;assembly=SilverlightHVP.View"         
    xmlns:vsm="clr-namespace:System.Windows;assembly=System.Windows"             
    d:DesignHeight="300" d:DesignWidth="400">
    <UserControl.Resources>
        <Style x:Key="ListBoxStyle1" TargetType="ListBox">
            <Setter Property="ScrollViewer.HorizontalScrollBarVisibility" Value="Hidden"/>
            <Setter Property="ScrollViewer.VerticalScrollBarVisibility" Value="Hidden"/>
            <Setter Property="ItemTemplate">
                <Setter.Value>
                    <DataTemplate>
                            <StackPanel HorizontalAlignment="Stretch">
                                <Image Source="{Binding Image}" HorizontalAlignment="Left"/>
                                <TextBlock Text="{Binding TextToDisplay}" Style="{StaticResource StdText}" FontSize="16" Foreground="White" Margin="0, 0, 0, 5"/>
                            </StackPanel>
                    </DataTemplate>
                </Setter.Value>
            </Setter>
            
        </Style>

        <Style TargetType="ListBoxItem" x:Key="ListBoxItemStyle1">
            <Setter Property="Padding" Value="20" />
            <Setter Property="HorizontalContentAlignment" Value="Left" />
            <Setter Property="VerticalContentAlignment" Value="Top" />
            <Setter Property="Background" Value="Transparent" />
            <Setter Property="BorderThickness" Value="1"/>
            <Setter Property="TabNavigation" Value="Local" />
            <Setter Property="Template">
                <Setter.Value>
                    <ControlTemplate TargetType="ListBoxItem">
                        <Grid Background="{TemplateBinding Background}">
                            <vsm:VisualStateManager.VisualStateGroups>
                                <vsm:VisualStateGroup x:Name="CommonStates">
                                    <vsm:VisualState x:Name="Normal" />
                                    <vsm:VisualState x:Name="MouseOver">
                                        <Storyboard>
                                            <DoubleAnimation Storyboard.TargetName="fillColor" Storyboard.TargetProperty="Opacity" Duration="0" To=".35"/>
                                        </Storyboard>
                                    </vsm:VisualState>
                                    <vsm:VisualState x:Name="Disabled">
                                        <Storyboard>
                                            <DoubleAnimation Storyboard.TargetName="contentPresenter" Storyboard.TargetProperty="Opacity" Duration="0" To=".1" />
                                        </Storyboard>
                                    </vsm:VisualState>
                                </vsm:VisualStateGroup>
                                <vsm:VisualStateGroup x:Name="SelectionStates">
                                    <vsm:VisualState x:Name="Unselected" />
                                    <vsm:VisualState x:Name="Selected">
                                        <Storyboard>
                                            <DoubleAnimation Storyboard.TargetName="fillColor2" Storyboard.TargetProperty="Opacity" Duration="0" To=".75"/>
                                        </Storyboard>
                                    </vsm:VisualState>
                                </vsm:VisualStateGroup>
                                <vsm:VisualStateGroup x:Name="FocusStates">
                                    <vsm:VisualState x:Name="Focused">
                                        <Storyboard>
                                            <ObjectAnimationUsingKeyFrames Storyboard.TargetName="FocusVisualElement" Storyboard.TargetProperty="Visibility" Duration="0">
                                                <DiscreteObjectKeyFrame KeyTime="0">
                                                    <DiscreteObjectKeyFrame.Value>
                                                        <Visibility>Visible</Visibility>
                                                    </DiscreteObjectKeyFrame.Value>
                                                </DiscreteObjectKeyFrame>
                                            </ObjectAnimationUsingKeyFrames>
                                        </Storyboard>
                                    </vsm:VisualState>
                                    <vsm:VisualState x:Name="Unfocused"/>
                                </vsm:VisualStateGroup>
                            </vsm:VisualStateManager.VisualStateGroups>


                            <Border BorderBrush="#33FFFFFF" BorderThickness="0,0,0,1" IsHitTestVisible="False"/>
                            <Rectangle x:Name="fillColor" Opacity="0" Fill="#AAFFFFFF" IsHitTestVisible="False" RadiusX="1" RadiusY="1"/>
                            <Rectangle x:Name="fillColor2" Opacity="0" Fill="#AAFFFFFF" StrokeThickness="0" IsHitTestVisible="False" RadiusX="1" RadiusY="1"/>
                            
                            <ContentPresenter
                              x:Name="contentPresenter"
                              Content="{TemplateBinding Content}"
                              ContentTemplate="{TemplateBinding ContentTemplate}"
                              HorizontalAlignment="{TemplateBinding HorizontalContentAlignment}"
                              Margin="{TemplateBinding Padding}"
                             />


                            <Rectangle x:Name="FocusVisualElement" Stroke="#FFFFFF" StrokeThickness="0" Visibility="Collapsed" RadiusX="1" RadiusY="1" />
                        </Grid>
                    </ControlTemplate>
                </Setter.Value>
            </Setter>
        </Style>
    </UserControl.Resources>
    
    
    <Grid x:Name="LayoutRoot" Margin="0,10,0,10">
        <this:ScrollBox>
            <ListBox x:Name="LinksList"
               Background="Transparent"
               BorderThickness="0"
               ItemsSource="{Binding Links}"
               SelectedItem="{Binding CurrentLink, Mode=TwoWay}"
               Style="{StaticResource ListBoxStyle1}"
               ItemContainerStyle="{StaticResource ListBoxItemStyle1}"
               IsEnabled="{Binding IsValid}"     
               />
        </this:ScrollBox>
   </Grid>
</UserControl>
